package com.venus.mq.zk;

import org.I0Itec.zkclient.ZkClient;

/**
 * Created by mc on 18/11/20.
 */
public class ZkServiceImpl implements ZkService {

    public  ZkClient zkClient;

    public ZkServiceImpl( ZkClient zkClient) {

        this.zkClient = zkClient;
    }


    @Override
    public Boolean isExist(String zkPath) {
        return zkClient.exists(zkPath);
    }


    @Override
    public Boolean delete(String zkPath) {
        return zkClient.delete(zkPath);
    }


    @Override
    public void write(String zkPath, Object object) {
        zkClient.writeData(zkPath,object);
    }


    @Override
    public Object read(String zkPath) {
        return zkClient.readData(zkPath);
    }

    @Override
    public void createPerNode(String zkPath) {
        zkClient.createPersistent(zkPath);
    }

    @Override
    public void crateTemNode(String zkPath) {
        zkClient.createEphemeral(zkPath);
    }

}
